<template>
  <el-dropdown trigger="click" @command="setAssemblySize">
    <i :class="'iconlayout iconly-contentright'" class="toolBar-icon"></i>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          v-for="item in assemblySizeList"
          :key="item.value"
          :command="item.value"
          :disabled="assemblySize === item.value"
        >
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { type AssemblySizeType } from "@/management/store/layouts/interface";
import { useStore } from 'vuex'
const store = useStore()

const assemblySize = computed(() => store.state.layouts.globalState.assemblySize);

const assemblySizeList = [
  { label: "默认", value: "default" },
  { label: "大型", value: "large" },
  { label: "小型", value: "small" }
];

const setAssemblySize = (item: AssemblySizeType) => {
  if (assemblySize.value === item) return;
  store.dispatch('layouts/setGlobalState', { "assemblySize": item })
};
</script>
